package com.bjb.vr.common.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bjb.vr.common.dto.ResDevice;
import com.bjb.vr.common.dto.ResDeviceContent;
import com.bjb.vr.common.mapper.ResDeviceContentMapper;
import com.bjb.vr.common.result.BaseResult;
import com.bjb.vr.common.result.CommonResult;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author admin
* @description 针对表【res_device_content(设备安装课程表)】的数据库操作Service
* @createDate 2022-04-11 15:15:47
*/
@Service
public class ResDeviceContentService extends ServiceImpl<ResDeviceContentMapper,ResDeviceContent> {

    @Autowired
    ResDeviceContentMapper resDeviceContentMapper;

    public BaseResult deleteResDeviceSetupCourseByUdid(String udid){

        if(StringUtils.isEmpty(udid)){
            CommonResult.Fail("设备唯一标识不能为空");
        }
        LambdaQueryWrapper<ResDeviceContent> wrapper = Wrappers.lambdaQuery(ResDeviceContent.class);
        wrapper.eq(ResDeviceContent::getUdid,udid);
        this.remove(wrapper);
        return CommonResult.Ok();

    }

    public BaseResult saveBatchResDeviceSetupCourseList(List<ResDeviceContent> resDeviceContentList){
        resDeviceContentMapper.saveBatchResDeviceSetupCourseList(resDeviceContentList);
        return CommonResult.Ok();
    }
}
